mui.init();
mui.plusReady(function() {
	//	window.addEventListener('refreshdom', function(event) {
	//		console.log(event.detail.val);
	//		userindex.reqcode(event.detail.val);
	//	})
	var userindex = new Vue({
		el: "#app",
		data: {
			data:[],

		},
		mounted: function() {
			var _this = this;
			
			_this.$nextTick(function() {
				_this.cartView();
			});

		},
		methods: {
			cartView: function() {
				var _this = this;
				_this.data=[];
				var data = app.getcar();
				for(var p in data){
					var tempdata = data[p];
					tempdata['count'] = 1;
					_this.data.push(tempdata)
				}
				

			},
			refresh: function(done) {
				done();
			},
			infinite: function(done) {
				done();
			},
			openwin: function(gid,count){
				mui.openWindow({
					url: 'buyord.html',
					id: 'buyord',
					extras: {
						name: 'mui',
						nid: gid,
						count: count
					}
				});
			},
			clicknum: function(type,index){
				var _this = this;
				if(type ==1){
					if(_this.data[index].count <= 1){
						_this.data[index].count = 1;
					}else{
						_this.data[index].count --;
					}
					
				}else{
					_this.data[index].count ++;
				}
			},
			delCar: function(uid){
				app.delcar(uid);
				this.cartView();
			}
			
		}

	});
	
	var swiper = new Swiper('.swiper-container', {
		pagination: {
			el: '.swiper-pagination',
		},
		autoplay: true,
	});

});